package cn.wolfcode.trip.base.service.impl;

import cn.wolfcode.trip.base.domain.DailyNewsComment;
import cn.wolfcode.trip.base.mapper.DailyNewsCommentMapper;
import cn.wolfcode.trip.base.query.DailyNewsCommentQuery;
import cn.wolfcode.trip.base.service.IDailyNewsCommentService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DailyNewsCommentServiceImpl implements IDailyNewsCommentService {
    @Autowired
    private DailyNewsCommentMapper dailyNewsCommentMapper;

    @Override
    public void deleteByPrimaryKey(Long id) {

    }

    @Override
    public void insert(DailyNewsComment record) {
        dailyNewsCommentMapper.insert(record);
    }

    @Override
    public DailyNewsComment selectByPrimaryKey(Long id) {
        return null;
    }

    @Override
    public List<DailyNewsComment> selectAll() {
        return null;
    }

    @Override
    public void updateByPrimaryKey(DailyNewsComment record) {

    }

    @Override
    public PageInfo<DailyNewsComment> selectForComment(DailyNewsCommentQuery qo) {
        PageHelper.startPage(qo.getCurrentPage(),qo.getPageSize(),qo.getOrderBy());
        List<DailyNewsComment> dailyNewsComments = dailyNewsCommentMapper.selectForComment(qo);
        return new PageInfo<>(dailyNewsComments);
    }

    @Override
    public Integer selectByNewsId(Long news_id) {
        return dailyNewsCommentMapper.selectByNewsId(news_id);
    }

    public PageInfo selectByUserId(DailyNewsCommentQuery qo) {
        PageHelper.startPage(qo.getCurrentPage(),qo.getPageSize(),qo.getOrderBy());
        List<DailyNewsComment> list = dailyNewsCommentMapper.selectByUserId(qo);
        return new PageInfo(list);
    }
}
